June 28, 1991 Changed 60 Hz to 60.15 Hz, as specified by Apple.
Here are two simple improvement that you can make to the THINK C profiler. The first will allow it to work even when interrupts are turned off. The second changes the printout to be in units of time, instead of arbitrary ticks.
The new VIA_ticks() routine in THINK C 4.0 has the virtue, relative to the preceding version, that it uses interrupts to handle overflow of the VIA clock, so the clock won't overflow even if VIA_ticks() is called very infrequently. However, the new code has the disadvantage that it won't work if interrupts are turned off (by raising the processor priority). Some of my code runs with interrupts off for performance reasons. Obviously I want to be able to time its performance with interrupts off. A trivial change to the new VIA_ticks() routine provides the best of both worlds. Every call to VIA_ticks() resets the timer, postponing the overflow, so VIA_ticks() will work even if interrupts are disabled. Of course it will still overflow if interrupts are disabled AND calls to VIA_ticks() are too infrequent.
In the C Libraries folder in your THINK C folder double click the profiler project. Now, in the routine VIA_ticks() in the file VIA_timer.c replace:
elapsed.word.lo = ~timer.word;
by this:
VIA[vT1C] = VIA[vT1CH] = ~0;
elapsed.dword += ~timer.word;
Recompile (Command-K) and quit.
You may wish to make another change. This is purely cosmetic, converting the profiler printout to reasonable units of time, instead of arbitrary ticks. Open the file profile.c and find the routine DumpProfile(). Just before the routine insert the following definitions:
#ifdef _VIATIMER_
#define S 1.2766 /* microseconds per VIA tick */
#define UNIT "(µs)"
#else
#define S (1e3/60.15) /* milliseconds per 60.15 Hz tick */
#define UNIT "(ms)"
#endif
Then, within the routine, replace the two printf statements by the following modified printf's: